import request from '@/axios'

export interface SysRole {
  roleId?: number
  roleName: string
  roleCode: string
  roleType?: string
  systemCode?: string
  isEnable?: number
  createUserId?: number
  createUserName?: string
  createTime?: string
  updateUserId?: number
  updateUserName?: string
  updateTime?: string
}

export interface RoleQueryParams {
  pageNum?: number
  pageSize?: number
  roleName?: string
  roleCode?: string
  roleType?: string
}

// 分页查询角色列表
export const getRoleListApi = (params: RoleQueryParams) => {
  return request.post({ url: '/api/system/role/list', data: params })
}

// 查询所有角色列表（不分页）
export const getAllRolesApi = () => {
  return request.get({ url: '/api/system/role/all' })
}

// 根据ID查询角色详情
export const getRoleDetailApi = (id: number) => {
  return request.get({ url: `/api/system/role/${id}` })
}

// 新增角色
export const addRoleApi = (data: SysRole) => {
  return request.post({ url: '/api/system/role', data })
}

// 更新角色
export const updateRoleApi = (id: number, data: SysRole) => {
  return request.put({ url: `/api/system/role/${id}`, data })
}

// 删除角色
export const deleteRoleApi = (id: number) => {
  return request.delete({ url: `/api/system/role/${id}` })
}

// 批量删除角色
export const batchDeleteRoleApi = (ids: number[]) => {
  return request.delete({ url: '/api/system/role/batch', data: ids })
}
